﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.BLL;
using PBOffice.Models;
using AjaxControlToolkit;

public partial class PBOfficeMaster : System.Web.UI.MasterPage
{
    List<SysFun> list = new SysFunManager().GetAllSysFun();
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
            //this.lbUser.Text = Session["username"].ToString();
            string date = DateTime.Now.Year.ToString() + "年" + DateTime.Now.Month.ToString() + "月" + DateTime.Now.Day.ToString() + "日";
            string week = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
            this.lbTime.Text = date + week;
            Display();

        //}
    }
    private void Display()
    {        //循环将学生ID添加到Accordion控件的标题中
        int id = 1;
        int hlId = 1;
        foreach (SysFun item in list)
        {

            AccordionPane ap = new AccordionPane(); //实例化一个AccordionPane 控件
            ap.ID = "ap" + id.ToString();
            Image img = new Image();
            Label lblStudentMenu = new Label(); //实例化一个标签控件用来显示分类名 
            if (item.ParentNodeId == 0)
            {
                img.ImageUrl = "~/imges/middle_left_1.jpg";
                img.ID = "img" + id.ToString();
                lblStudentMenu.Text = item.DisplayName.ToString();//指定标签的Text属性为分类名 
                lblStudentMenu.ID = "lb" + id.ToString();
                ap.HeaderContainer.Controls.Add(img);
                ap.HeaderContainer.Controls.Add(lblStudentMenu); //将标签控件添加到AccordionPane标题部分 
                List<SysFun> child = new SysFunManager().GetAllSysFunByParId(item.NodeId);
                foreach (SysFun sys in child)
                {
                    Image img2 = new Image();
                    img2.ID = "img" + hlId.ToString();
                    img2.ImageUrl = "~/imges/middle_left_2.jpg";
                    ap.ContentContainer.Controls.Add(img2);
                    HyperLink hlinkStudentMenu = new HyperLink();
                    hlinkStudentMenu.CssClass = "hlink";
                    hlinkStudentMenu.ID = "hl" + hlId.ToString();
                    hlinkStudentMenu.Text = "    " + sys.DisplayName + "<br>";//指定HyperLink的Text属性为学生姓名  
                    hlinkStudentMenu.NavigateUrl = sys.NodeURL; //指定连接属性                
                    ap.ContentContainer.Controls.Add(hlinkStudentMenu);//将连接控件添加到AccordionPane内容部分 
                    hlId += 1;
                }


            }
            id += 1;
            Accordion1.Panes.Add(ap);//将AccordionPane追加到Accordion的Panes集合中  
        }

    }


}
